package mao.leetcode.others.leetcode633;

class Solution {
    public boolean judgeSquareSum(int c) {

        int left=0,right=(int)Math.sqrt(c);
        long tmp=0;


        while(left <= right){
            tmp = (long)left*left+right*right;
            if(tmp == c){
                return true;
            }else if (tmp < c){
                left++;
            }else{
                right--;
            }
        }

        return false;
    }

    public static void main(String[] args) {
        Solution solution = new Solution();
        boolean b = solution.judgeSquareSum(4);
        System.out.println(b);
    }
}